package o;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnShowListener;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import o.ewm.n;

public class ehk extends cku {
    private a ॱ;

    public interface a {
        void ˋ();
    }

    public static ehk ˋ(Context context, CharSequence charSequence, CharSequence charSequence2) {
        try {
            ehk o_ehk = new ehk();
            Bundle bundle = new Bundle();
            bundle.putCharSequence("tileContent", charSequence);
            bundle.putCharSequence("content", charSequence2);
            o_ehk.setArguments(bundle);
            o_ehk.setCancelable(false);
            return o_ehk;
        } catch (Exception e) {
            return new ehk();
        }
    }

    public Dialog onCreateDialog(Bundle bundle) {
        Dialog create = ˋ(getActivity()).create();
        create.setCancelable(false);
        create.setOnShowListener(new OnShowListener(this) {
            final /* synthetic */ ehk ˎ;

            {
                this.ˎ = r1;
            }

            public void onShow(DialogInterface dialogInterface) {
                ((AlertDialog) dialogInterface).getButton(-1).setOnClickListener(new OnClickListener(this) {
                    final /* synthetic */ AnonymousClass4 ˊ;

                    {
                        this.ˊ = r1;
                    }

                    public void onClick(View view) {
                        if (this.ˊ.ˎ.ˊ != null) {
                            this.ˊ.ˎ.ˊ.ˏ();
                        }
                    }
                });
                ((AlertDialog) dialogInterface).getWindow().addFlags(8192);
                if (this.ˎ.ॱ != null) {
                    this.ˎ.ॱ.ˋ();
                }
            }
        });
        return create;
    }

    protected Builder ˋ(Context context) {
        Bundle arguments = getArguments();
        if (arguments != null) {
            this.ˏॱ = arguments.getCharSequence("tileContent");
            this.ˋॱ = arguments.getCharSequence("content");
        }
        Builder builder = new Builder(context);
        builder.setTitle(this.ˏॱ);
        if (TextUtils.isEmpty(this.ˋॱ)) {
            builder.setMessage(null);
        } else {
            builder.setMessage(this.ˋॱ);
        }
        builder.setPositiveButton(n.ˊʾ, null);
        if (this.ʽ == 0) {
            builder.setNegativeButton(n.ˊˈ, new DialogInterface.OnClickListener(this) {
                final /* synthetic */ ehk ˊ;

                {
                    this.ˊ = r1;
                }

                public void onClick(DialogInterface dialogInterface, int i) {
                    if (!ActivityUtil.isAcitivtyNotValid(this.ˊ.getActivity())) {
                        if (this.ˊ.ˊ != null) {
                            this.ˊ.ˊ.upgrade();
                        }
                        this.ˊ.dismissAllowingStateLoss();
                    }
                }
            });
        }
        if (this.ʻ == 0) {
            builder.setNeutralButton(this.ॱॱ, new DialogInterface.OnClickListener(this) {
                final /* synthetic */ ehk ॱ;

                {
                    this.ॱ = r1;
                }

                public void onClick(DialogInterface dialogInterface, int i) {
                    if (!ActivityUtil.isAcitivtyNotValid(this.ॱ.getActivity())) {
                        if (this.ॱ.ˊ != null) {
                            this.ॱ.ˊ.ˋ();
                        }
                        this.ॱ.dismissAllowingStateLoss();
                    }
                }
            });
        }
        if (this.ʼ != null) {
            builder.setView(this.ʼ);
        }
        return builder;
    }

    public void ˏ(a aVar) {
        this.ॱ = aVar;
    }
}
